#!/usr/bin/make -f

%:
	dh ${@}


override_dh_auto_build:
	# Remove Electron bundle
	sed -i '/"electron":/d' package.json
	sed -i '/"electron-builder":/d' package.json
	sed -i '/"electron-notarize":/d' package.json
	
	# Remove ffmpeg dependencies, use the system one
	sed -i '/"ffmpeg-ffprobe-static":/d' package.json
	
	# Do not generate png icon because system supports svg one
	sed -i 's/yarn icon-gen && //g' package.json
	
	# Do not install dependencies, we install it with apt
	sed -i '/"postinstall":/d' package.json
	
	# Build
	yarn
	yarn run build
	yarn install --production --ignore-scripts --prefer-offline
	cp src/icon.svg lossless-cut.svg
	
	# Patch electron-is-dev
	echo 'module.exports = false;' > node_modules/electron-is-dev/index.js
	
	# Delete unused files
	rm -f node_modules/*/{CHANGELOG.md,README.md,README,readme.md,readme}
	rm -rf node_modules/.cache

